<?php

/**
 * $Id: PDO.php 11 2010-11-24 22:10:53Z LEON $
 * $Author: LEON $
 * $LastChangedDate: 2010-11-24 22:10:53 +0000 (Wed, 24 Nov 2010) $
 * $Revision: 11 $
 */

namespace cmFly\db;

use cmFly\db\PDO\statement;

class PDO extends \PDO implements iDb {
    public function __construct($dsn, $username = '', $password = '', $options = array(\PDO::MYSQL_ATTR_USE_BUFFERED_QUERY => true, \PDO::ATTR_ERRMODE => \PDO::ERRMODE_EXCEPTION)) {
	parent::__construct($dsn, $username, $password, $options);
	$this->setAttribute(PDO::ATTR_STATEMENT_CLASS, Array('\cmFly\db\PDO\statement'));
    }

    /**
     * @method prepare
     * @return \cmFly\db\PDO\statement
     */

    /**
     * @method query
     * @return \cmFly\db\PDO\statement
     */
    public function get_one($sql, $fetch_type=\PDO::FETCH_BOTH) {
	return $this->query($sql)->fetch($fetch_type);
    }
    public function get_db_type() {
	return $this->getAttribute(self::ATTR_DRIVER_NAME);
    }
    public function get_constructor($to) {
	$class=__NAMESPACE__.'\\sql_constructors\\'.$this->get_db_type().'\\'.$to;
	return new $class($this);
    }
}